﻿Imports System.IO


Public Class GestionTest

    Public Function BuscaTest() As List(Of String)
        Dim ficheros As New List(Of String)
        Dim misFicheros() As String = Directory.GetFiles(My.Application.Info.DirectoryPath & "\Ficheros", "*.txt")
        For Each misArchivo In misFicheros
            Dim misArch() As String = misArchivo.Split("\")

            ficheros.Add(misArch(misArch.Length - 1))

        Next
        Return ficheros
    End Function


    Public Function EliminarFichero(ficheroParaEliminar As String) As String
        Try
            File.Delete(My.Application.Info.DirectoryPath & "\Ficheros\" & ficheroParaEliminar)
            Return "Eliminado correctamente"
        Catch e As Exception
            Return "No se ha eliminado"
        Finally

        End Try
    End Function
    Public Function CrearTest(tema As String) As Test
        'Dim nuevoTest As StreamReader

        File.Create(My.Application.Info.DirectoryPath & "\Ficheros\" & tema & ".txt")
        Dim unTema As New Test
        unTema.Tema = tema

        Return unTema
    End Function
End Class
